#include "Precompiled.hpp"
#include "Player_impl.h"
#include <cassert>
#include <mmsystem.h>
#include <iostream>
#pragma comment(lib, "vfw32.lib")

Player_impl::Player_impl()
{
}
Player_impl::~Player_impl()
{
}
void Player_impl::Init(HWND hwnd, HINSTANCE hInst)
{
    playerWnd_ = MCIWndCreate(hwnd, hInst, 
        /*MCIWNDF_NOTIFYPOS|*/MCIWNDF_NOMENU|MCIWNDF_NOERRORDLG/*|MCIWNDF_NOTIFYMODE|MCIWNDF_SHOWALL*/,
        NULL);
    ShowWindow(playerWnd_, SW_HIDE);
}
bool Player_impl::OpenFile(const std::wstring& file_name)
{
    return MCIWndOpen(playerWnd_, file_name.c_str(), NULL) == 0;
}

bool Player_impl::CloseFile()
{
    return MCIWndClose(playerWnd_) == 0;
}
bool Player_impl::Play()
{
    return ( MCIWndPlay(playerWnd_) == 0);
}

bool Player_impl::PlayFromTo(long start_pos, long end_pos)
{
    return MCIWndPlayFromTo(playerWnd_, start_pos, end_pos) == 0;
}

long Player_impl::GetFileLength()
{
    return MCIWndGetLength(playerWnd_);
}
long Player_impl::GetCurrentPos()
{
    return MCIWndGetPosition(playerWnd_);
}

bool Player_impl::PlayFrom(long pos)
{
    return MCIWndPlayFrom(playerWnd_, pos) == 0;
}
bool Player_impl::Pause()
{
    return (MCIWndPause(playerWnd_) == 0);
}

bool Player_impl::Stop()
{
    return (MCIWndStop(playerWnd_) == 0);
}
